<template>
  <div class="Collection">
    <van-sticky>
      <van-row class="select-item">
        <van-col v-for="(item, index) in selectlist" :key="index">
          <span :class="formData.itemActive == item.id ? 'selectactive' : ''" @click="getmore(item.id, index)">{{
              item.name
          }}</span>
        </van-col>
      </van-row>
    </van-sticky>
    <van-list v-model:loading="formData.loading" :finished="formData.finished" @load="onload" finished-text="我是有底线的~"
      v-if="CollectionLists.length >= 1">
      <van-grid :column-num="formData.grid">
        <van-grid-item v-for="(item, index) in CollectionLists" :key="index" :gutter="40">
          <div class="sellStaus" v-if="item.whereabouts">
            {{ item.whereabouts == 1 ? "出售中" : "转赠中" }}
          </div>
          <div class="sellStaus" v-if="item.bidStatus == 0">竞价中</div>
          <div class="" :class="formData.grid == 1 ? 'widthwarp' : 'col-warp'">
            <div class="Content-product">
              <div class="videoContainer" v-if="!VideoIndexOf(item.collectionCover)" @click="GoInner(item)">
                <vdeo :collection="item.collectionCover" />
                <div class="number">X {{ item.sumTotalNumber }}</div>
              </div>
              <div class="img-box" :style="'background-image:url(' + item.collectionCover + ') '" @click="GoInner(item)"
                v-if="VideoIndexOf(item.collectionCover)">
                <div class="number">X {{ item.sumTotalNumber }}</div>
              </div>
              <div class="cont">
                <p>{{ item.collectionName }}</p>
                <div class="code">{{ item.userCode }}</div>
                <van-row class="flex-warp">
                  <van-col span="10" class='txt'>{{ item.className ? item.className : "" }}</van-col>
                  <van-col span="14" class="linercolor">￥{{ item.amount }}</van-col>
                </van-row>
              </div>
            </div>
          </div>
        </van-grid-item>
      </van-grid>
    </van-list>
    <van-empty :image="require('@/assets/image/none.png')" description="暂无数据" v-if="CollectionLists.length <= 0" />
  </div>
</template>
<script>
import { defineComponent, ref, reactive, toRefs, onMounted } from 'vue'
import { useStore } from "vuex";
import { useRouter } from "vue-router"
import { VideoIndexOf } from "@/utils/phone";
import { collectionList, IPageByState, cancelSell, openBlindBox } from "@/api/public";
import vdeo from '@/components/video.vue';
export default defineComponent({
  components: { vdeo },
  props: {
    menulist: {
      type: Array
    }
  },
  setup(props) {
    const store = useStore();
    const router = useRouter()
    const formData = reactive({
      sellStatus: null,
      finished: false,
      loading: true,
      pageNum: 1,
      pageSize: 1,
      total: 0,
      seabhidden: false,
      rankShow: true,
      itemActive: null,
      grid: 2,
      keywords: "",
      propType: 0,
    })
    const tabList = ref([])
    const CollectionLists = ref([])
    const onload = async () => {
      const data = {
        pageSize: formData.size,
        pageNum: formData.pageNum,
      }
      const res = await collectionList(formData)
      console.log(res.data.data.records)
      formData.loading = false
      formData.pageNum++
      formData.total = res.data.data.total
      CollectionLists.value = CollectionLists.value.concat(res.data.data.records)
      if (formData.total <= CollectionLists.value.length) {
        formData.finished = true;
      }
      formData.loading = false
    }
    onMounted(() => {
      onload()
    })
    const GoInner = (item) => {
      if (item.bidStatus == 0) {
        if (item.sumTotalNumber >= 2) {
          router.push({
            path: '/morecolletion',
            query: {
              id: item.collectionId
            }
          })
        } else {
          router.push({
            path: '/auction',
            query: {
              id: item.auctionId,
              type: item.bidStatus
            }
          })
        }
        return false
      }
      if (item.sumTotalNumber >= 2) {
        router.push({
          path: '/morecolletion',
          query: {
            id: item.collectionId
          }
        })
      } else {
        router.push({
          path: '/Mycollectioninner',
          query: {
            id: item.collectionId,
            type: 0,
            userCollectionId: item.userCollectionId
          }
        })
      }
    }
    const selectlist = reactive([
      { id: null, name: "全部状态" },
      { id: 0, name: "出售中" },
      { id: 1, name: "赠与中" },
    ])


    const onSearch = () => {

    }
    const onCancel = () => {

    }
    const getmore = (id, index) => {
      formData.pageNum = 1
      CollectionLists.value = []
      formData.itemActive = id
      formData.sellStatus = id
      formData.loading = true
      formData.finished = false
      onload()
    }
    const getmenu = (id, index, type) => {
      console.log(id, index, type)
      formData.seabhidden = !formData.seabhidden
      formData.tabActive = index
      const data = {
        sell: 1,
        pageSize: formData.size,
        pageNum: formData.pageNum,
      }
    }
    return {
      onload, formData, selectlist, tabList, getmore, getmenu, CollectionLists, onSearch, onCancel, GoInner, VideoIndexOf
    }

  }

})
</script>
<style lang="less" scoped>
.grid {
  position: relative;
}

.sellStaus {
  position: absolute;
  z-index: 9;
  background: rgba(0, 0, 0, 0.6);
  color: #eb0407;
  top: 50px;
  left: 40px;
  width: fit-content;
  border-radius: 10px;
  padding: 10px;
}

.code {
  font-size: 28px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #fefefe;
  padding: 10px 0px;
  background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.number {
  position: absolute;
  height: 28px;
  font-size: 30px;
  font-family: Source Han Sans CN;
  font-weight: 600;
  color: #fefefe;
  // background: rgba(0, 0, 0, 0.9);
  z-index: 999;
  bottom: 10px;
  right: 0;
  padding: 20px;
  background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.img-box {
  position: relative;

  video {
    width: 180px;
  }

  img {
    width: 27px;
    vertical-align: middle;
    margin-right: 5px;
  }

  .time-warp {
    color: #169900;
  }

  .seld-warp {
    color: #b9c4c7;
  }

  .light-warp {
    color: #f3e3bb;

    img {
      width: 17px;
      height: 24px;
    }
  }

  .warp {
    padding: 10px 20px;
    margin: 10px 12px 0px;
    background: #000000;
    border-radius: 26px;
    display: block;
    width: fit-content;
  }
}

&:deep(.van-search) {
  background: #202123;
}

&:deep(.van-field) {
  margin-bottom: 0px;
  background: transparent;
  height: auto;
}

&:deep(.van-search__action) {
  font-size: 30px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #b9c4c7;
  line-height: 18px;
}

&:deep(.van-search__content--square) {
  width: 628px;
  height: 68px;
  background: #282a2c;
  border-radius: 34px;
  padding-left: 20px;

  img {
    width: 32px;
    height: 32px;
    line-height: 68px;
    margin-left: 10px;
    margin-top: 6px;
  }
}

&:deep(.van-sticky--fixed) {
  background: #282a2c;
  height: auto !important;
}

&:deep(.van-hairline--top) {
  margin: 0px 10px;
  //   background: #161718;
  //   width: 94%;
  //   margin: 30px auto;
  border: none;
}

&:deep(.van-hairline--top:after) {
  border-top-width: 0px;
}

&:deep(.van-grid-item__content) {
  padding: 30px 0px 0px;
  background: transparent;
}

&:deep(.van-hairline:after) {
  border: none;
}

&:deep(.van-grid-item) {
  background: transparent;
}

.col-warp {
  .videoContainer {
    video {
      width: 334px;
      height: 334px;
    }

    width: 334px;
    height: 334px;
    position: relative;
    overflow: hidden;
    border-radius: 40px 40px 0px 0px;
    border: 1px solid #ffffff;

    .fullscreenVideo {
      width: 100%;
      height: 334px;
    }
  }

  // .videoContainer {
  //   width: 334px;
  //   height: 334px;
  //   border-radius: 40px 40px 0px 0px;
  //   border: 2px solid #ffffff;
  // }
  .Content-product {
    border-radius: 40px 40px 0px 0px;
    background: linear-gradient(to bottom, #4b4c4d, #161718);
    width: 344px;
    // height: 543px;
    background: #282a2c;
    border-radius: 40px;

    .cont {
      padding: 15px 12px;

      p {
        height: 50px;
        font-size: 28px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;
        line-height: 50px;
      }

      .txt {
        font-size: 26px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #b9c4c7;
        line-height: 48px;
      }

      .linercolor {
        text-align: right;
        font-size: 40px;
        font-family: Source Han Sans CN;
        font-weight: bold;
        color: #ffffff;
        line-height: 50px;
        background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }

      .flex-warp {
        display: flex;
        align-items: center;
      }

      .Limit-warp {
        margin: 10px 0;

        span {
          font-size: 26px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          line-height: 48px;
        }

        span:nth-child(1) {
          color: #444442;
          font-size: 26px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          background: #f3e3bb;
          border-radius: 4px 0px 0px 4px;
          padding: 3px 12px;
        }

        span:nth-child(2) {
          padding: 3px 12px;
          background: #ffffff;
          border-radius: 4px;
          font-size: 26px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #f3e3bb;
          line-height: 48px;
        }
      }
    }

    .img-box {
      padding-top: 20px;
      width: 100%;
      box-sizing: border-box;
      height: 334px;
      background-size: cover;
      border-radius: 40px 40px 0px 0px;
      border: 2px solid #ffffff;
      background-repeat: no-repeat;
      background-position: center center;
      overflow: hidden;
    }
  }
}

.widthwarp {
  width: 708px !important;

  .Content-product {
    border-radius: 40px 40px 0px 0px;
    background: linear-gradient(to bottom, #4b4c4d, #161718);
    width: 708px !important;
    // height: 543px;
    background: #282a2c;
    border-radius: 40px;

    .cont {
      padding: 30px 30px 30px 37px;

      p {
        font-size: 28px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;
      }

      .txt {
        font-size: 26px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #b9c4c7;
        line-height: 48px;
      }

      .linercolor {
        text-align: right;
        font-size: 40px;
        font-family: Source Han Sans CN;
        font-weight: bold;
        color: #ffffff;
        line-height: 73px;

        background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }

      .flex-warp {
        display: flex;
        align-items: center;
      }

      .Limit-warp {
        margin-top: 20px;

        span {
          font-size: 26px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          line-height: 48px;
        }

        span:nth-child(1) {
          color: #444442;
          font-size: 26px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          background: #f3e3bb;
          border-radius: 4px 0px 0px 4px;
          padding: 3px 12px;
        }

        span:nth-child(2) {
          padding: 3px 12px;
          background: #ffffff;
          border-radius: 4px;
          font-size: 26px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #f3e3bb;
          line-height: 48px;
        }
      }
    }

    .warp {
      margin-top: 20px;
      margin-left: 47px;
      padding: 14px 30px;
    }

    .img-box {
      padding-top: 40px;
      width: 708px !important;
      height: 708px !important;
      background-size: cover;
      border-radius: 40px 40px 0px 0px;
      border: 2px solid #ffffff;
      background-repeat: no-repeat;
      background-position: center center;
      overflow: hidden;
    }
  }
}

.all-select {
  margin-top: 30px;
  background: #282a2c;
  padding: 26px 21px;
  display: flex;

  &:deep(.van-col) {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;

    span {
      font-size: 30px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #ffffff;
      line-height: 30px;
    }

    img {
      width: 28px;
      height: 16px;
      margin-left: 10px;
    }
  }

  .rank {
    img {
      width: 48px;
      height: 48px;
    }
  }

  .upper {
    display: none;
    // transform: rotate(360deg);
    // transform: rotate(90deg);
  }

  .lower {
    display: block;
  }

  @keyframes masked-animation {
    0% {
      transform: rotate(0deg);
    }

    100% {
      transform: rotate(360deg);
    }
  }

  @keyframes opacity-animation {
    0% {
      opacity: 0;
    }

    100% {
      opacity: 1;
    }
  }

  .tabactive {
    span {
      font-size: 30px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #3d94ff;
      line-height: 30px;
      background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .upper {
      display: block !important;
      animation: masked-animation 0.5s;
      -webkit-animation: masked-animation 0.5s;
      transform: rotate(360deg);
    }

    .lower {
      animation: masked-animation 1s linear;
      -webkit-animation: masked-animation 1s linear;
      display: none !important;
    }
  }
}

.select-item {
  .selectactive {
    background: #282a2c;
    border: 1px solid #ffffff;
    color: #ffffff;
  }

  span {
    margin-top: 10px;
    padding: 22px 36px;
    display: inline-block;
    background: #282a2c;
    border-radius: 34px;
    font-size: 28px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #b9c4c7;
    line-height: 18px;
    margin-left: 20px;
  }
}
</style>